var myformUtils = {
	data_formFillByAllNames : undefined,
	//独立计算订单总数	
	getOrderPorderTotal:function(){
		var length = 0;
		if($(".source_factory_colresizeable").length>0){
			length=parseInt(tbsourcefactoryColresizeEvent.index_x_no);
		}
		if($(".source_factory_colresizeable_for_two").length>0){
			length=parseInt(tbsourcefactoryColresizeEventForTwo.index_x_no);
		}
		
		var smallOrderTotal=0;//每一行订单small最大数之和
		var orderTotal=0;
		//如果外部有大订单数 为每一行大订单数之和
		if($("[name='order_s_order_total']").length>0){
			for(var i=0;i<length;i++){
				var everyOrder=[];
				//组件一
				$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).parents("tr").find("[name='order_s_order_total']").each(function(index,el){
					everyOrder.push(($(this).text().length>0)?parseInt($(this).text()):0);
				})
				//组件二
				$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(i).parents("tr").find("[name='order_s_order_total']").each(function(index,el){
					everyOrder.push(($(this).text().length>0)?parseInt($(this).text()):0);
				})
				//选出该行最大的订单数
				if(everyOrder.length>0){
					orderTotal+=everyOrder.sort(function(a,b){return a-b;})[everyOrder.length-1];
				}
			}
			return orderTotal;
		}
		//如果外部没有大订单数 为每一行大订单数之和
		if($("[name='order_s_small_order_total']").length>0){
			for(var i=0;i<length;i++){
				var everySmallOrder=[];
				//组件一
				$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).parents("tr").find("[name='order_s_small_order_total']").each(function(index,el){
					everySmallOrder.push(($(this).text().length>0)?parseInt($(this).text()):0);
				})
				//组件二
				$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(i).parents("tr").find("[name='order_s_small_order_total']").each(function(index,el){
					everySmallOrder.push(($(this).text().length>0)?parseInt($(this).text()):0);
				})
				//选出该行最大的订单数
				if(everySmallOrder.length>0){
					smallOrderTotal+=everySmallOrder.sort(function(a,b){return a-b;})[everySmallOrder.length-1];
				}
			}
			return smallOrderTotal;
		}
		//2019.2.25没有物料组件二三的时候 source_factory_colresizeable source_factory_colresizeable_for_two 订单总数变成 1
		if($(".source_factory_colresizeable").length<1&&$(".source_factory_colresizeable_for_two").length<1){
			return 1;
		}
		return 0;
	},//给相应的区域组件赋值
	initdataforarea:function(orderInfo,orderInfoDetail,orderInfoTail,orderCustomTag){
		table_order_info.order_p_deptid=orderInfo["order_p_deptid"];
		table_order_info.order_p_audit=orderInfo["order_p_audit"];table_order_info.readonly();
		table_order_info.order_p_created=orderInfo["order_p_created"];//制单人
		table_order_info.order_p_order_make_time=orderInfo["order_p_order_make_time"];//制单时间
		table_order_info.order_p_audit_time=orderInfo["order_p_audit_time"];//审核时间
	},
    formToArrByAllNames:function(dom,name){
        var retdata={};
        $(dom).find("[name^='"+name+"']").each(function(i,elem){
        	//转换标点 排除逗号
            if($(elem)[0].tagName=="DIV"||$(elem)[0].tagName=="SPAN"){
                if(retdata[$(this).attr("name")]){
                    retdata[$(this).attr("name")]= 
                        retdata[$(this).attr("name")]+","+(($(this).text().length>0)?$(this).text().replace('请输入或选择',' '):" ");
                }else{
                    retdata[$(this).attr("name")]=(($(this).text().length>0)?$(this).text().replace('请输入或选择',' '):" ");
                }
            }
            
            if($(elem)[0].tagName=="TEXTAREA"||$(elem)[0].tagName=="INPUT"){
                if($(elem)[0].type=="checkbox"){
                    retdata[$(this).attr("name")]=$(this).is(":checked");;
                }else if($(elem)[0].type=="radio"){
                         
                }else{
                    if(retdata[$(this).attr("name")]){
                    retdata[$(this).attr("name")]= 
                        retdata[$(this).attr("name")]+","+(($(this).val().length>0)?$(this).val():" ");
                    }else{
                        retdata[$(this).attr("name")]=($(this).val().length>0)?$(this).val():" ";
                    }
                }
            }
            
            if($(elem)[0].tagName=="SELECT"){
                if(retdata[$(this).attr("name")]){
                    retdata[$(this).attr("name")]= 
                        retdata[$(this).attr("name")]+","+(($(this).val().length>0)?$(this).val():" ");
                }else{
                    retdata[$(this).attr("name")]=($(this).val().length>0)?$(this).val():" ";
                }
            }
            //table 自定义表格
            if($(elem)[0].tagName=="TD"){
                if(retdata[$(this).attr("name")]){
                    retdata[$(this).attr("name")]= 
                        retdata[$(this).attr("name")]+(($(this).html().length>0)?$(this).html():" ")+"~";
                }else{
                    //retdata[$(this).attr("name")]=($(this).html().length>0)?$(this).html():" ";
                    retdata[$(this).attr("name")]=($(this).html().length>0)?$(this).html()+"~":" "+"~";
                }
            }
            
        });
        //自定义标签 额外添加
        retdata["order_label_label_val"]=null;
        $(dom).find("[name='order_label_label_val']").each(function(i,elem){
        	if(retdata["order_label_label_val"]){
        		if($(elem)[0].tagName=="DIV"){
        			retdata["order_label_label_val"]=retdata[$(this).attr("name")]+"~"+(($(this).html().length>0)?$(this).html():" ");
        		}else{
        			retdata["order_label_label_val"]=retdata[$(this).attr("name")]+"~"+(($(this).val().length>0)?$(this).val():" ");
        		}
        	}else{
        		if($(elem)[0].tagName=="DIV"){
        			retdata["order_label_label_val"]=(($(this).html().length>0)?$(this).html():" ");
        		}else{
        			retdata["order_label_label_val"]=(($(this).val().length>0)?$(this).val():" ");
        		}
        	}
        });
        retdata["order_label_label_val"]=retdata["order_label_label_val"]+"~";
        
        retdata["order_s_table_source_arr"]=basic_index.getSaveTemplateInfoData()["order_s_table_source_arr"];
        retdata["order_template_id"]=basic_index.template_id;//订单模版关系

        var order_s_table_source_arr_str=basic_index.getBigMaterialDataByOrder()["order_s_table_source_arr_str"];
        retdata["order_s_table_source_arr_str"]=order_s_table_source_arr_str;
        retdata["save_as_new_order"]=basic_index.save_as_new_order;
        retdata["order_p_order_total"]=this.getOrderPorderTotal();
        //增加订单明细物料代码
        retdata["line_no_material_code"]=this.getLineNoMaterialCode();
        //增加总投料数
        if(true||$("[name='order_p_feed_total']").length<1||$("[name='order_p_feed_total']").val().length<1){retdata["order_p_feed_total"]=tbsourcefactoryColresizeEvent.feedTotalBlur();}
        //增加原始制单人避免多人编辑导致修改
        retdata["order_p_created"]=table_order_info.order_p_created;
        //获取行号 修正多个物料大组件问题 此处仅限2个物料大组件
        if(retdata["order_s_line_no"]!=null&&retdata["order_s_line_no"].lastIndexOf(",1,")>0){
        	retdata["order_s_line_no"]=retdata["order_s_line_no"].substr(0,retdata["order_s_line_no"].lastIndexOf(",1,"));
        }
        if(retdata["order_s_line_no"]=="1,1"){//排除只有两个组件只有1行的情况下导致反馈到后台1,1的错误
        	retdata["order_s_line_no"]="1";
        }
        //大货时间
        retdata["special_dh_date"]=basic_index.getBigMaterialDataByOrder()["special_dh_date"];
        //重新计算外部订单数和外部投料数
        var reCaluFeedTotalAndOrderTotalJSON = this.reCaluFeedTotalAndOrderTotal(retdata["order_s_feed_total"],retdata["order_s_order_total"]);
        if(reCaluFeedTotalAndOrderTotalJSON["order_s_feed_total"]!=undefined){
        	retdata["order_s_feed_total"]=reCaluFeedTotalAndOrderTotalJSON["order_s_feed_total"];
        }
        if(reCaluFeedTotalAndOrderTotalJSON["order_s_order_total"]!=undefined){
        	retdata["order_s_order_total"]=reCaluFeedTotalAndOrderTotalJSON["order_s_order_total"];
        }
        //制单时间不应该随着修改而修改
        if(table_order_info.order_p_audit==1){
        	retdata["order_p_order_make_time"] = table_order_info.order_p_order_make_time;
        	retdata["order_p_audit_time"] = table_order_info.order_p_audit_time;
        }
        //查看所有分类仓的数据 并且合并
        var data_flc=[];
        for(var i=0;i<$("[src='big_type_content_info.html']").length;i++){
			if(i==0){
				data_flc=$("[src='big_type_content_info.html']")[0].contentWindow.bigTypeContent.getRowData();
			}else{
				data_flc = data_flc.concat($("[src='big_type_content_info.html']")[i].contentWindow.bigTypeContent.getRowData());
			
			}
        }
        data_flc=JSON.stringify(data_flc);
        retdata["data_classification"] = data_flc;
        return retdata;
    },
    formFillByAllNames:function(dom,data){
        //console.info(data);
    	myformUtils.data_formFillByAllNames = data;
        var orderInfo = data.orderInfo;
        var orderInfoDetail = data.orderInfoDetail;
        //传入物料大组件校验组件行号和数据总行号是否相等
        //alert(data.order_s_line_no_total);
        if(tbsourcefactoryColresizeEvent)tbsourcefactoryColresizeEvent.checkLineNoTotalIsMatchHtmlLineTotal(data.order_s_line_no_total);
        var orderInfoTail = data.orderInfoTail;
        var orderCustomTag = data.orderCustomTag;
        //给相应的区域组件赋值
        this.initdataforarea(orderInfo,orderInfoDetail,orderInfoTail,orderCustomTag);
        
        if(orderInfo==null){
            alert("查无订单数据,请核实");
            return;
        }
        //用于二维数组
        var table_source_arr = basic_index.getBigMaterialDataByOrderFromStorage()["order_s_table_source_arr"].split("-");//区分行中第几个
        var table_source_arr_str = eval(basic_index.getBigMaterialDataByOrderFromStorage()["order_s_table_source_arr_str"]);//区分行中第几个
        var table_source_line_total =localStorage.getItem("table_source_line_total");//第几行
        /*增加外部写入的时候总行号和模板不一样*/
        if(data.order_s_line_no_total)table_source_line_total=data.order_s_line_no_total;
        var table_model_index=0;
        /*订单主表*/
        //localStorage.setItem("order_p_audit",orderInfo["order_p_audit"]);
        $(dom).find("[name^='order_p_']").each(function(i,elem){
            if($(elem)[0].type=="checkbox"){
            	if(orderInfo[$(this).attr("name")]==1){
            		$(this).prop("checked",(orderInfo[$(this).attr("name")]));  
            	}
            }else if($(elem)[0].type=="radio"){
                
            }else{
                if($(elem)[0].tagName=="DIV"||$(elem)[0].tagName=="SPAN"){
                    $(this).text(orderInfo[$(this).attr("name")]);
                }

                if($(elem)[0].tagName=="TEXTAREA"||$(elem)[0].tagName=="INPUT"){
                    $(this).val(orderInfo[$(this).attr("name")]);
                }

                if($(elem)[0].tagName=="SELECT"){
                    $(this).val(orderInfo[$(this).attr("name")]);
                }
            }
            
        })
        
        //例外 圈图 腿图
        if(orderInfo["order_p_pic_quan"]&&orderInfo["order_p_pic_quan"]!=" "){
            uploadpic_quan.showpic_quan(orderInfo["order_p_pic_quan"]);
        }
        if(orderInfo["order_p_pic_tui"]&&orderInfo["order_p_pic_tui"]!=" "){
            uploadpic_tui.showpic_tui(orderInfo["order_p_pic_tui"]);
        }
        
        /*订单明细表*/
        var nametypearr={};
        var order_s_material_code_index=0;
        var order_s_material_house_index=0;
        var order_s_material_type_index=0;
        var order_s_isReadColor_index=0;
        var el_index=-1;
        /**
         * 设置每个大组件顺序
         */
        var bigOne = 0;//大组件1
        var bigTwo = 1;//大组件2
        //alert($(dom).find("table[class^='source_factory_colresizeable']").length);
        for(var bigIndex = 0 ; bigIndex < $(dom).find("table[class^='source_factory_colresizeable']").length ; bigIndex ++){
        	if($(dom).find("table[class^='source_factory_colresizeable']").eq(bigIndex).attr("class") == "source_factory_colresizeable JColResizer"){
        		bigOne = bigIndex;
        	}
        	if($(dom).find("table[class^='source_factory_colresizeable']").eq(bigIndex).attr("class") == "source_factory_colresizeable_for_two JColResizer" ){
        		bigTwo = bigIndex;
        	}
        }
        console.info("bigOne"+bigOne);
        console.info("bigTwo"+bigTwo);
        for(var index=0;index<table_source_arr_str.length;index++){//有几个大组件
        	
        	for(var i=0;i<table_source_line_total;i++){//第几行
                for(j=0;j<table_source_arr[index].split(",").length;j++){//第几列
                    el_index++;//从json中取对应数据使用
                    //console.info("el_index:"+el_index);
                    //console.info(el_index);
                    console.info(orderInfoDetail[el_index]);
                    if(!table_source_arr_str[index]){
                    	break;
                    }
                    var str = table_source_arr_str[index][j];
                    for(var key in orderInfoDetail[el_index]){
                        //console.info("key ： "+key+"^"+str)
                    	/*nametypearr[key]=(!isNaN(nametypearr[key]))?parseInt(nametypearr[key])+1:0;
                        var tagIndex = nametypearr[key];*/
                    	if(str.indexOf(key)<0){//不存在的时候
                    		//物料代码排除
                    		if(key=='order_s_material_code' && str.indexOf("order_s_material_color")>-1){//有色号才有code
                        		$(dom).find("[name='"+key+"']").eq(order_s_material_code_index).val(orderInfoDetail[el_index][key]);
                        		order_s_material_code_index++;
                    		}
                    		if(key=='order_s_material_house' && i==0){
                        		$(dom).find("[name='"+key+"']").eq(order_s_material_house_index).val(orderInfoDetail[el_index][key]);
                        		order_s_material_house_index++;
                    		}
                    		if(key=='order_s_material_type' && i==0){
                        		$(dom).find("[name='"+key+"']").eq(order_s_material_type_index).text(orderInfoDetail[el_index][key]);
                        		order_s_material_type_index++;
                    		}
                    		if(key=='order_s_isReadColor' && i==0){//是否读颜色
                        		$(dom).find("[name='"+key+"']").eq(order_s_isReadColor_index).val(orderInfoDetail[el_index][key]);
                        		order_s_isReadColor_index++;
                    		}
                    		continue;
                    	}
                    	nametypearr[key]=(!isNaN(nametypearr[key]))?parseInt(nametypearr[key])+1:0;
                        var tagIndex = nametypearr[key];
                        if(
                            $(dom).find("[name='"+key+"']").eq(tagIndex)[0]
                                &&
                            ($(dom).find("[name='"+key+"']").eq(tagIndex)[0].tagName=="DIV"
                                ||
                             $(dom).find("[name='"+key+"']").eq(tagIndex)[0].tagName=="SPAN")){
                            $(dom).find("[name='"+key+"']").eq(tagIndex).text(orderInfoDetail[el_index][key]);
                        }

                        if(
                            $(dom).find("[name='"+key+"']").eq(tagIndex)[0]
                                &&
                            ($(dom).find("[name='"+key+"']").eq(tagIndex)[0].tagName=="TEXTAREA"
                             ||
                             $(dom).find("[name='"+key+"']").eq(tagIndex)[0].tagName=="INPUT")){
                        	$(dom).find("[name='"+key+"']").eq(tagIndex).val(orderInfoDetail[el_index][key]);
                        }

                        if($(dom).find("[name='"+key+"']").eq(tagIndex)[0]&&$(dom).find("[name='"+key+"']").eq(tagIndex)[0].tagName=="SELECT"){
                            $(this).val(orderInfoDetail[el_index][key]);
                        }
                        //add tbsourcefactoryEvent.table_source_type_arr
                        if(i==0){
                        	tbsourcefactoryEvent.table_source_type_arr[j]=orderInfoDetail[el_index]["order_s_material_type"];
                        }
                    }
                    //例外 规格型号  可能单行多个
                    //console.info(table_source_arr[j]==3);
                    /*if(table_source_arr[j]==3){
                        $(dom).find("[name='order_s_material_model']").eq(table_model_index).text(orderInfoDetail[el_index]["order_s_material_model"]);
                        table_model_index++;
                    }*/
                    if(table_source_arr_str[index].toString()==eval(getLocalInfo("temp_info_table_source_arr_str").toString())
                    		&&(orderInfoDetail[el_index]["order_s_material_type"]=="订单数"||orderInfoDetail[el_index]["order_s_material_type"]=="投料数")){
                    	//订单数  投料数 单行单个
                    	if(index != bigOne){
                    		continue;
                    	}
                        if(orderInfoDetail[el_index]&&orderInfoDetail[el_index]["order_s_material_type"]=="订单数")$(dom).find(".source_factory_colresizeable").find("[name='order_s_order_total']").eq(i).text(orderInfoDetail[el_index]["order_s_order_total"]);

                        if(orderInfoDetail[el_index]&&orderInfoDetail[el_index]["order_s_material_type"]=="投料数")$(dom).find(".source_factory_colresizeable").find("[name='order_s_feed_total']").eq(i).text(orderInfoDetail[el_index]["order_s_feed_total"]);
                        //例外 行号  单行单个
                        $(dom).find(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).text(i+1);
                        continue;
                    }
                    if(table_source_arr_str[index].toString()==eval(getLocalInfo("temp_info_table_source_arr_str_for_two").toString())
                    		&&(orderInfoDetail[el_index]["order_s_material_type"]=="订单数"||orderInfoDetail[el_index]["order_s_material_type"]=="投料数")){
                    	//订单数  投料数 单行单个
                    	if(index != bigTwo){
                    		continue;
                    	}
                        if(orderInfoDetail[el_index]&&orderInfoDetail[el_index]["order_s_material_type"]=="订单数")$(dom).find(".source_factory_colresizeable_for_two").find("[name='order_s_order_total']").eq(i).text(orderInfoDetail[el_index]["order_s_order_total"]);

                        if(orderInfoDetail[el_index]&&orderInfoDetail[el_index]["order_s_material_type"]=="投料数")$(dom).find(".source_factory_colresizeable_for_two").find("[name='order_s_feed_total']").eq(i).text(orderInfoDetail[el_index]["order_s_feed_total"]);
                        //例外 行号  单行单个
                        $(dom).find(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(i).text(i+1);
                        continue;
                    }
                    
                }
            }
        }
        /*订单明细tail表*/
		//需要排除分类仓  20200522
		var myneworderInfoTail = [];
		$.each(orderInfoTail,function(index,content){
			if (content["order_s_input_val_classification"] == null || content["order_s_input_val_classification"].length == 0){
				myneworderInfoTail.push(content);
			}
		})
		console.info(myneworderInfoTail);
        $.each(myneworderInfoTail,function(index,content){
            for(var key in content){
                //console.info(key+":"+$(dom).find("[name='"+key+"']").eq(index)[0].tagName);
                if(
                    $(dom).find("[name='"+key+"']").eq(index)[0]
                        &&
                    ($(dom).find("[name='"+key+"']").eq(index)[0].tagName=="DIV"
                        ||
                     $(dom).find("[name='"+key+"']").eq(index)[0].tagName=="SPAN")){
                    //console.info(1);
                    $(dom).find("[name='"+key+"']").eq(index).text(content[key]);
                }

                if(
                    $(dom).find("[name='"+key+"']").eq(index)[0]
                        &&
                    ($(dom).find("[name='"+key+"']").eq(index)[0].tagName=="TEXTAREA"
                     ||
                     $(dom).find("[name='"+key+"']").eq(index)[0].tagName=="INPUT")){
                    //console.info(2);
                    $(dom).find("[name='"+key+"']").eq(index).val(content[key]);
                }

                if($(dom).find("[name='"+key+"']").eq(index)[0]&&$(dom).find("[name='"+key+"']").eq(index)[0].tagName=="SELECT"){
                    //console.info(3);
                    $(dom).find("[name='"+key+"']").eq(index).val(content[key]);
                }
            }
        })
        /*自定义标签*/
        if(orderCustomTag!=null){
        	if(orderCustomTag['order_label_label_val']!=null){
        		$(dom).find("[name='order_label_label_val']").each(function(i,elem){
        			if(orderCustomTag['order_label_label_val'].indexOf("~")>-1){//存在~
        				if($(this)[0].tagName=="DIV"){$(this).html(orderCustomTag['order_label_label_val'].split("~")[i]);}
            			if($(this)[0].tagName=="TEXTAREA"){$(this).val(orderCustomTag['order_label_label_val'].split("~")[i]);}
        			}else{//不然就是老的数据,
        				if($(this)[0].tagName=="DIV"){$(this).html(orderCustomTag['order_label_label_val'].split(",")[i]);}
            			if($(this)[0].tagName=="TEXTAREA"){$(this).val(orderCustomTag['order_label_label_val'].split(",")[i]);}
        			}
                });
        	}
        	if(orderCustomTag['order_label_table_val']!=null){
        		$(dom).find("[name='order_label_table_val']").each(function(i,elem){
        			if(orderCustomTag['order_label_table_val'].indexOf("~")>-1){//存在~
        				$(this).html(orderCustomTag['order_label_table_val'].split("~")[i]);
        			}else{
        				$(this).html(orderCustomTag['order_label_table_val'].split(",")[i]);
        			}
                });
        	}
        	if(orderCustomTag['order_label_table_val_two']!=null){
	            $(dom).find("[name='order_label_table_val_two']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_two'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_two'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_two'].split(",")[i]);
	            	}
	            });
        	}
        	if(orderCustomTag['order_label_table_val_three']!=null){
	            $(dom).find("[name='order_label_table_val_three']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_three'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_three'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_three'].split(",")[i]);
	            	}
	            });
        	}
        	if(orderCustomTag['order_label_table_val_four']!=null){
	            $(dom).find("[name='order_label_table_val_four']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_four'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_four'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_four'].split(",")[i]);
	            	}
	            });
        	}
        	if(orderCustomTag['order_label_table_val_five']!=null){
	            $(dom).find("[name='order_label_table_val_five']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_five'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_five'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_five'].split(",")[i]);
	            	}
	            });
        	}
        	//6
        	if(orderCustomTag['order_label_table_val_six']!=null){
	            $(dom).find("[name='order_label_table_val_six']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_six'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_six'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_six'].split(",")[i]);
	            	}
	            });
        	}
        	//7
        	if(orderCustomTag['order_label_table_val_seven']!=null){
	            $(dom).find("[name='order_label_table_val_seven']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_seven'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_seven'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_seven'].split(",")[i]);
	            	}
	            });
        	}
        	//8
        	if(orderCustomTag['order_label_table_val_eight']!=null){
	            $(dom).find("[name='order_label_table_val_eight']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_eight'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_eight'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_eight'].split(",")[i]);
	            	}
	            });
        	}
        	//9
        	if(orderCustomTag['order_label_table_val_nine']!=null){
	            $(dom).find("[name='order_label_table_val_nine']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_nine'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_nine'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_nine'].split(",")[i]);
	            	}
	            });
        	}
        	//10
        	if(orderCustomTag['order_label_table_val_ten']!=null){
	            $(dom).find("[name='order_label_table_val_ten']").each(function(i,elem){
	            	if(orderCustomTag['order_label_table_val_ten'].indexOf("~")>-1){
	            		$(this).html(orderCustomTag['order_label_table_val_ten'].split("~")[i]);
	            	}else{
	            		$(this).html(orderCustomTag['order_label_table_val_ten'].split(",")[i]);
	            	}
	            });
        	}
        }
        /**
         * 填充物料代码到序号中
         */
        if(orderInfoDetail!=undefined){//避免没有物料明细数据导致错误
        	for(var i=0;i<orderInfoDetail.length;i++){
            	var material_house = orderInfoDetail[i].order_s_material_house;
            	var material_type = orderInfoDetail[i].order_s_material_type;
            	var material_code = orderInfoDetail[i].order_s_material_code;
            	var line_no = parseInt(orderInfoDetail[i].order_s_line_no);
            	if(material_house!=3){//排除3 信息备注仓
            		if(tbsourcefactoryColresizeEvent.table_source_type_arr().join(",").indexOf(material_type)>-1){//大组件一
            			$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(line_no-1).data(material_type+"|"+material_house,material_code);
            		}
            		if(tbsourcefactoryColresizeEventForTwo.table_source_type_arr().join(",").indexOf(material_type)>-1){//大组件二
            			$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(line_no-1).data(material_type+"|"+material_house,material_code);
            		}
            	}
            }
        	//设置大货时间
            var special_dh_date=data["special_dh_date"].replace("&",",").split(",");
            $("[name='special_dh_date']").each(function(index,el){
            	$(this).text(special_dh_date[index]);
            })
        }
        this.fillDataEnd();
    },
    formClearAll:function(dom,name){
    	console.info("formClearAll");
        $(dom).find("[name^='"+name+"']").each(function(i,elem){
            if($(elem)[0].tagName=="TEXTAREA"&&$(this).attr("name")!='order_label_label_val'){
            	$(this).val("");
            }
            if($(elem)[0].tagName=="DIV"){
                if($(this).attr("contenteditable")){
                	if($(this).attr("name")=='order_label_label_val'){
                		
                	}else{
                		$(this).text("");//请输入或选择
                	}
                }
                if($(this).attr("name")=='order_label_label_val'){
                    //$(this).text("");
                }
                if($(this).attr("name")=='order_s_order_total'||$(this).attr("name")=='order_s_feed_total'){
                    $(this).text("0");
                }
            }
            if($(elem)[0].tagName=="SELECT"){
                $(this).val("");
            }
            if($(elem)[0].type=="checkbox"){
                $(this).removeAttr('checked'); 
            }
            if($(elem)[0].type=="radio"){
                $(this).removeAttr('checked'); 
            }
            if($(elem)[0].tagName=="TD"){
            	if($(elem).attr("name").indexOf("order_label_table_val")>-1){
            		
            	}else{
                    $(this).text(""); 
            	}
            }
        })
    },//通过myformUtils.formToArrByAllNames("#myformsubmit","order_");填充数据
    formFillByJson:function(dom,domname,data){
    	//name order_
    	console.info(data);
    	var nameIndex={};
        $(dom).find("[name^='"+domname+"']").each(function(i,elem){
        	var name=$(this).attr("name");
        	nameIndex[name]=(!isNaN(nameIndex[name]))?parseInt(nameIndex[name])+1:0;
        	if(name=='order_p_order_no'){//排除订单编号
        		return;
        	}
        	console.info(data[name]);
        	var everyData = ((data[name]+"").indexOf("~")>-1)?(data[name]+"").split("~"):(data[name]+"").split(",");
            if($(elem)[0].tagName=="DIV"||$(elem)[0].tagName=="SPAN"){
            	if(name=="order_label_label_val"){
            		$(this).html(everyData[nameIndex[name]]);
            	}else{
            		$(this).text(everyData[nameIndex[name]]);
            	}
            }
            
            if($(elem)[0].tagName=="TEXTAREA"||$(elem)[0].tagName=="INPUT"){
                if($(elem)[0].type=="checkbox"){
                	$(this).prop("checked",(everyData[nameIndex[name]]));  
                }else if($(elem)[0].type=="radio"){
                         
                }else{
                	$(this).val(everyData[nameIndex[name]]);
                }
            }
            
            if($(elem)[0].tagName=="SELECT"){
            	$(this).val(everyData[nameIndex[name]]);
            }
            //table
            if($(elem)[0].tagName=="TD"){
            	$(this).html(everyData[nameIndex[name]]);
            }
            //例外 圈图 腿图
            if(name=="order_p_pic_quan"){
            	if(everyData[nameIndex[name]]&&everyData[nameIndex[name]]!=" "){
    	            uploadpic_quan.showpic_quan(everyData[nameIndex[name]]);
    	        }
            }
            if(name=="order_p_pic_tui"){
		        if(everyData[nameIndex[name]]&&everyData[nameIndex[name]]!=" "){
		            uploadpic_tui.showpic_tui(everyData[nameIndex[name]]);
		        }
            }
        })
        //设置大货时间
        var special_dh_date=data["special_dh_date"].replace("&",",").split(",");
        $("[name='special_dh_date']").each(function(index,el){
        	$(this).text(special_dh_date[index]);
        })
        //设置分类仓
        if(data["data_classification"]){
        	var bigTypeData = eval(data["data_classification"]);
    		$("[src='big_type_content_info.html']").each(function(){
    			var id = $(this).parents(".draggable").find("[id^='easyuipanel_']").attr("id");
    	    	//util.js
    	    	var title = getEasyuiPanel(id).title;
    	    	for(var dataIndex = 0; dataIndex<bigTypeData.length ; dataIndex++){
    	    		if(bigTypeData[dataIndex]["classification"] == title){
    	    			$(this)[0].contentWindow.bigTypeContent.parentAppendRow(bigTypeData[dataIndex]);
    	    		}
    	    	}
    		})
        }
        

    },
    //获取序号物料和code的组合  序号_物料类型_原材料_code
    getLineNoMaterialCode:function(){
    	var str = "";
    	//物料大组件1
    	for(var i=0;i<$(".source_factory_colresizeable").find("[name='order_s_line_no']").length;i++){
    		console.info($(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).data());
    		/*for(var key in $(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).data()){
    			if(tbsourcefactoryColresizeEvent.table_source_type_arr().join(",").indexOf(key.split("|")[0])<0){
    				continue;
    			}
        		str+=$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).text()+"|"+key+"@"+$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).data(key)+","
        	}*/
    		var	order_s_material_house_data = $(".source_factory_colresizeable").find('[name="order_s_material_house"]').map(function(){return $(this).val()}).get();
    		for(var j=0;j<tbsourcefactoryColresizeEvent.table_source_type_arr().length;j++){
    			var key =tbsourcefactoryColresizeEvent.table_source_type_arr()[j]+"|"+order_s_material_house_data[j];
    			if($(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).data(key)){//存在这个可以
            		str+=$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).text()+"|"+key+"@"+$(".source_factory_colresizeable").find("[name='order_s_line_no']").eq(i).data(key)+","
    			}
    		}
    	}
    	//物料大组件2
    	for(var j=0;j<$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").length;j++){
    		console.info($(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).data());
    		/*for(var key in $(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).data()){
    			if(tbsourcefactoryColresizeEventForTwo.table_source_type_arr().join(",").indexOf(key.split("|")[0])<0){
    				continue;
    			}
        		str+=$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).text()+"|"+key+"@"+$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).data(key)+","
        	}*/
    		var	order_s_material_house_data = $(".source_factory_colresizeable_for_two").find('[name="order_s_material_house"]').map(function(){return $(this).val()}).get();
    		for(var i=0;i<tbsourcefactoryColresizeEventForTwo.table_source_type_arr().length;i++){
    			var key =tbsourcefactoryColresizeEventForTwo.table_source_type_arr()[i]+"|"+order_s_material_house_data[i];
    			if($(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).data(key)){//存在这个可以
            		str+=$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).text()+"|"+key+"@"+$(".source_factory_colresizeable_for_two").find("[name='order_s_line_no']").eq(j).data(key)+","
    			}
    		}
    	}
    	console.info(str.substring(0,str.length-1));
    	return str.substring(0,str.length-1);
    },
    //订单数据填充完毕的事件
    fillDataEnd:function(){
    	//如果需要刷新保存订单页面为图片 refreshTemplateImg
    	if(window.location.href.indexOf("refreshTemplateImg")>-1){
    		menubuttonIndexTool.saveAsBase64img();
    	}
    },
    //上传保存订单信息的时候重新判断订单数和投料数问题
    //由于有一个有有一个没有导致数据赋值给第一个出现的组件中了
    reCaluFeedTotalAndOrderTotal:function(sourceFeedTotalArg,sourceOrderTotalArg){
    	var json={};
    	//初始化原数据
    	json["order_s_feed_total"]=sourceFeedTotalArg;
    	json["order_s_order_total"]=sourceOrderTotalArg;
    	//校验
    	if($("table[class^=source_factory_colresizeable]").length==2){//两个组件同时出现的时候
    		//如果组件一行数加上组件二行数 不等于 外部订单数或则投料数之和
        	var allLineNoTotal=$("table[class^=source_factory_colresizeable]").find("[name='order_s_line_no']").length;
        	var half_allLineNoTotal=$("table[class^=source_factory_colresizeable]").find("[name='order_s_line_no']").length/2;
        	var allFeedTotal=$("table[class^=source_factory_colresizeable]").find("[name='order_s_feed_total']").length;
        	var allOrderTotal=$("table[class^=source_factory_colresizeable]").find("[name='order_s_order_total']").length;
        	var bc_OrderTotalOrFeedTotal="";
        	for(var half_allLineNoTotal_Index=0;half_allLineNoTotal_Index<=half_allLineNoTotal-1;half_allLineNoTotal_Index++){
        		bc_OrderTotalOrFeedTotal+=","
        	}
        	console.info(bc_OrderTotalOrFeedTotal)
    		//如果总行号比总订单数数量或则总投料数数量多的话
        	if(allLineNoTotal>allOrderTotal&&allOrderTotal!=0){
        		$("table[class^=source_factory_colresizeable]").each(function(index,el){
            		if(index==0){//只看第一个
            			// 如果有订单数 说明下一个组件没有则往后面增加订单数 如果没有订单数 则往前面加
            			if($(this).find("[name='order_s_order_total']").length>0){
            				json["order_s_order_total"]=json["order_s_order_total"]+bc_OrderTotalOrFeedTotal;
            			}else{
            				json["order_s_order_total"]=bc_OrderTotalOrFeedTotal+json["order_s_order_total"];
            			}
            		}
            	})
        	}
        	if(allLineNoTotal>allFeedTotal&&allFeedTotal!=0){
        		$("table[class^=source_factory_colresizeable]").each(function(index,el){
            		if(index==0){//只看第一个
            			// 如果有投料数 说明下一个组件没有则往后面增加投料数 如果没有投料数 则往前面加
            			if($(this).find("[name='order_s_feed_total']").length>0){
            				json["order_s_feed_total"]=json["order_s_feed_total"]+bc_OrderTotalOrFeedTotal;
            			}else{
            				json["order_s_feed_total"]=bc_OrderTotalOrFeedTotal+json["order_s_feed_total"];
            			}
            		}
            	})
        	}
    	}
    	console.info(json);
    	return json;
    }
    
}